<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <title>添加授课</title>
</head>
<style>
    .layui-form{
        height: 250px;
       padding-top: 30px;
    }
    .buttonOne{
       width: 50%;
       height: 40px;
       margin-top: 50px;
       padding-left: 40%;
    }
    .buttonOne button{
        margin-left: 20px;
    }
    .layui-input, .layui-textarea{
        width: 70%;
    }
    .layui-form-label{
        padding: 9px 30px;
    }
    .layui-form-select .layui-edge{
      right: 28%;
    }
    .layui-form-select dl{
            min-width: 70%;
            left: 30px;
        }
      
</style>
<body>
    <form class="layui-form" action="" id="form">
            <div class="layui-form-item">
                    <label class="layui-form-label">课&nbsp;&nbsp;程&nbsp;&nbsp;名</label>
                    <div class="layui-input-block">
                        <select name="as_co_id" lay-verify="required">
                        <option value=""></option>
                        <c:forEach items="${courses}" var="item">
                        	<option value="${item.co_id}">${item.course}</option>
                        </c:forEach>
                        </select>
                    </div>
                    </div>
                    <div class="layui-form-item">
                            <label class="layui-form-label">授课老师</label>
                            <div class="layui-input-block">
                                <select name="as_te_id" lay-verify="required">
                                <option value=""></option>
                        		<c:forEach items="${teachers}" var="item">
		                        	<option value="${item.te_id}">${item.te_truename}</option>
		                        </c:forEach>
                                </select>
                            </div>
                            </div>
                    <div class="layui-form-item">
                            <label class="layui-form-label">班级编号</label>
                            <div class="layui-input-block">
                                <select name="as_cl_id" lay-verify="required">
                                <option value=""></option>
                                <c:forEach items="${classs}" var="item">
                        			<option value="${item.cl_id}">${item.class_name}</option>
                        		</c:forEach>
                                </select>
                            </div>
                            </div>
        <div class="layui-form-item">
                <label class="layui-form-label">年</label>
                <div class="layui-input-block">
                    <input name="as_term" type="text" id="yearSelect" class="layui-input yearSelect year">
                </div>
        </div>
        <div class="layui-form-item">
                <div class="layui-input-block buttonOne">
                    <button class="layui-btn btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn layui-btn-warm">重置</button>
                </div>
                
            </div>
    </form>
    
</body>
<script>
    $(function(){
    	
    	layui.use(['laydate','form'],function(){
    	      var form = layui.form;
    	      var laydate = layui.laydate,
				layer = layui.layer,
				$ = layui.jquery

    	      laydate.render({
    	          elem: '#yearSelect',
    	          type: 'year',
    	          min:0
    	   	  });
    	});
    	$(".btn").click( function () {
    		var url="${pageContext.request.contextPath}/AssAdd";
    		var param=$("#form").serialize();
    		$.post(url,param,function(data){
    		 	if(data.flag==0){
    				alert(data.msg);
    			}
    			if(data.flag==1){
    				window.parent.location.reload();//刷新父页面
			        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			        parent.layer.close(index);
    		        alert(data.msg);
    			} 
    		});
    	});
    })
</script>
</html>